home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / hugearr.zip / HUGESETN.C < prev    next >
C/C++ Source or Header  |  1992-04-02  |  1KB  |  44 lines

  1.  
  2. #define NOCOMM
  3. #include <windows.h>
  4. #include <memory.h>
  5.  
  6. #include "hugearr.h"
  7.  
  8. /* Copy multiple VB array elements into multiple huge array elements. */
  9. /* VBM: Declare Function VBHugeSetNum% Lib "hugearr.dll" Alias "VBHugeSetNum" (ByVal Index%, ByVal el&, ByVal nelem%, buffer As Any) */
  10. int FAR PASCAL
  11. VBHugeSetNum(int hArray, long element, int nelem, LPBYTE buffer)
  12.     {
  13.     HPBYTE    ToBegin;
  14.     HPBYTE    ToElem;   /* pointer to array element */
  15.     PHUGEDESC pArray;   /* pointer to array descriptor */
  16.  
  17.     DecCheckHandle(hArray);
  18.  
  19.     /* point to proper descriptor */
  20.     pArray = (PHUGEDESC) LocalLock(hLocalMem) + hArray;
  21.  
  22.     CheckNotAllocYet(pArray);
  23.     CheckSubscript(pArray, element, element + nelem - 1);
  24.  
  25.     /* calculate pointer to element */
  26.     ToBegin = (HPBYTE) GlobalLock(pArray -> handle);
  27.  
  28.     while (nelem-- > 0)
  29.         {
  30.         ToElem = ToBegin + HugeElementOffset(element, pArray->perseg, pArray->recsize);
  31.  
  32.         /* copy one element of data */
  33.         _fmemcpy(ToElem, buffer, pArray -> recsize);
  34.  
  35.         /* increment pointer to VB array to point to next element. */
  36.         buffer += pArray -> recsize;
  37.         element ++;
  38.         }
  39.  
  40.     GlobalUnlock(pArray -> handle);
  41.     LocalUnlock(hLocalMem);
  42.     return HA_OK;
  43.     }
  44.